package 实践.class_06;

class Account {
    private int id;
    private String name;
    private double balance;
    private double annualInterestRate;


    public Account() {
    }

    public Account(int id, String name, double balance, double annualInterestRate) {
        this.id = id;
        this.name = name;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    /**
     * 获取
     * @return id
     */
    public int getId() {
        return id;
    }

    /**
     * 设置
     * @param id
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return balance
     */
    public double getBalance() {
        return balance;
    }

    /**
     * 设置
     * @param balance
     */
    public void setBalance(double balance) {
        this.balance = balance;
    }

    /**
     * 获取
     * @return annualInterestRate
     */
    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    /**
     * 设置
     * @param annualInterestRate
     */
    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    public String toString() {
        return "Account{id = " + id + ", name = " + name + ", balance = " + balance + ", annualInterestRate = " + annualInterestRate + "}";
    }
    //取款
    public void withdraw(double amount) {
        if (amount > balance) {

        } else {
            balance -= amount;

        }
    }
    //存款
    public void deposit(double amount) {
        if (amount <= 0) {

        } else {
            balance += amount;

        }
    }
    //返回月利率
    public double getMonthlyInterest() {
        return annualInterestRate / 1200;
    }
    //输出账户信息
    public void print() {
        System.out.println(id);
        System.out.println(name);
        System.out.println(balance);
        System.out.println(getMonthlyInterest());
    }
}
